package com.ruoyi.rva.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.rva.domain.RvaApp;
import com.ruoyi.rva.service.IRvaAppService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 应用Controller
 * 
 * @author jiaodacailei
 * @date 2021-07-29
 */
@RestController
@RequestMapping("/rva/app")
public class RvaAppController extends BaseController
{
    @Autowired
    private IRvaAppService rvaAppService;

    /**
     * 查询应用列表
     */
    @PreAuthorize("@ss.hasPermi('rva:app:list')")
    @GetMapping("/list")
    public TableDataInfo list(RvaApp rvaApp)
    {
        startPage();
        List<RvaApp> list = rvaAppService.selectRvaAppList(rvaApp);
        return getDataTable(list);
    }

    /**
     * 导出应用列表
     */
    @PreAuthorize("@ss.hasPermi('rva:app:export')")
    @Log(title = "应用", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(RvaApp rvaApp)
    {
        List<RvaApp> list = rvaAppService.selectRvaAppList(rvaApp);
        ExcelUtil<RvaApp> util = new ExcelUtil<RvaApp>(RvaApp.class);
        return util.exportExcel(list, "应用数据");
    }

    /**
     * 获取应用详细信息
     */
    @PreAuthorize("@ss.hasPermi('rva:app:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(rvaAppService.selectRvaAppById(id));
    }

    /**
     * 新增应用
     */
    @PreAuthorize("@ss.hasPermi('rva:app:add')")
    @Log(title = "应用", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RvaApp rvaApp)
    {
        return toAjax(rvaAppService.insertRvaApp(rvaApp));
    }

    /**
     * 修改应用
     */
    @PreAuthorize("@ss.hasPermi('rva:app:edit')")
    @Log(title = "应用", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RvaApp rvaApp)
    {
        return toAjax(rvaAppService.updateRvaApp(rvaApp));
    }

    /**
     * 删除应用
     */
    @PreAuthorize("@ss.hasPermi('rva:app:remove')")
    @Log(title = "应用", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(rvaAppService.deleteRvaAppByIds(ids));
    }
}
